package com;

import java.io.File;


//程序主入口
public class master {
    private final static String sp = File.separator;

    public static void main(String[] args) {
        int argsLength = args.length;
        if (argsLength == 0) {
            showHelp();
        }
        if ((argsLength == 1 && args[0].equals("-help")) || argsLength > 2) {
            showHelp();
        }
        if (argsLength == 1) {
            showHelp();
        }
        if (argsLength == 2 && args[0].equals("-p")) {
            fly.run(pathAdjust(args[1]));
        }
        if (argsLength == 2 && !args[0].equals("-p")) {
            showHelp();
        }
    }

    /*展示脚本信息*/
    private static void showHelp() {
        System.out.println("\tThis is a one-click script to generate the updated version of the report.");
        System.out.println("\tDate of birth:\t2020-7-24-10:53");
        System.out.println("\tAuthor:\tXueYongJian");
        System.out.println("\tsource code address:\thttps://gitee.com/mloine/Html_16s.git");
        System.out.println("\temail:\tmloine@163.com");
        System.out.println("\t-----------------------------------------");
        System.out.println("\tScript parameters:\t-p Folder Result path");
        System.out.println("\t-----------------------------------------");
        System.out.println("\tOnly one parameter,have a good time");
    }

    /*去掉路劲末尾路劲符号*/
    public static String pathAdjust(String path) {
        int pathTailLength = path.length() - 1;
        String pathTail = path.substring(pathTailLength);
        if (pathTail.equals(sp)) {
            return path.substring(0, pathTailLength);
        }
        return path;
    }

}
